﻿using System;

namespace Vkontakte.Api.Operations
{
	[ApiMethod("photos.get")]
	public sealed class PhotosGetInAlbum
		: Base30ApiOperation
	{
		private Photo[] _photos;
		public PhotosGetInAlbum()
		{

		}

		protected override void Compile()
		{
			AddParameter("method", "photos.get");
			if ((!UserID.HasValue)||(!AlbumID.HasValue))
			{
				throw new ArgumentNullException();
			}
			
			AddParameter("uid", UserID.Value.ToString());
			AddParameter("aid", AlbumID.Value.ToString());

			base.Compile();
		}

		protected override void ParseData(string data)
		{
			ListingResponce responce = Serializer.LoadObjectXmlString<ListingResponce>(data);
			_photos = responce.Photos;
			base.ParseData(data);
		}

		public long? UserID { get; set; }
		public long? AlbumID { get; set; }

		public Photo[] GetResult()
		{
			return _photos;
		}
	}
}